online 3.0.2

📶 Library to check your Internet connectivity
Documentation

Features

  • Both asynchronous and blocking implementations.
  • IPv4 and IPv6 support.

How it works

  • Tries to connect to Chrome captive portal (using its domain name).
  • If fails, tries the Firefox one.
  • If both fail, the second error is returned to help with diagnostics.

Install

The library is available on crates.io. Simply add the next line to your project's Cargo.toml.

online = "3.0.1"

Synchronous

The async-std runtime is supported by default. But you can explicitly choose the blocking alternative.

online = { version = "3.0.1",  default-features = false, features = ["sync"] }

Use

📝 Please visit the examples and the full documentation if you want to learn the details.

use online::check;

#[async_std::main]
async fn main() {
    println!("Online? {}", check(None).await.is_ok());
    println!("Online (timeout)? {}", check(Some(5)).await.is_ok());
    println!("Online (`Result`)? {:?}", check(None).await.unwrap());
}